package com.she.iiicoursecenter;

import java.util.ArrayList;
import java.util.List;

import com.she.iiicoursecenter.bean.ViewChageDataBean;
import com.she.iiicoursecenter.event.connect.bean.GetContentBean;
import com.she.iiicoursecenter.event.connect.bean.GetContentListBean;
import com.she.iiicoursecenter.event.connect.bean.GetItemListBean;
import com.she.iiicoursecenter.event.connect.bean.GetMakeBean;
import com.she.iiicoursecenter.event.connect.bean.GetMsgBean;
import com.she.iiicoursecenter.event.connect.bean.SearchConditionedBean;
import com.she.iiicoursecenter.event.connect.bean.SearchContentBean;
import com.she.iiicoursecenter.eventmanager.KenEventManager;
import com.she.iiicoursecenter.manager.ResourceManager;
import com.she.iiicoursecenter.tools.Utils;
import android.app.Application;
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.content.pm.PackageManager.NameNotFoundException;
import android.os.Handler;
import android.os.Message;
import android.util.Log;

public class iiiApplication extends Application {
	
	//
	public static final String APIURL = "http://211.72.248.137/mic"; 
	public static final String DEVICE = "android";
	public static final String VER = "1.0";
	public String DEVICE_TOKEN ="" , tab2Date, tab2Slot, tab2Time;
	public boolean tab3InCourseSingle = false;
	public boolean tab2InCourseSingle = false;
	public boolean fadein = false;
	public boolean fadeout = false;
	public int msgCount = 0;
	public int itemListColorCount = -1;
	// tool class...
	public Utils mUtils;
	//
	private MainActivityGroup mMainActivityGroup;
	//
	public static boolean isDebug = false;
	//
	public int MSG_WHAT_CHANGEVIEW	=	1001;
	//
	public Handler mChangeViewHandler = new Handler(){

		@Override
		public void handleMessage(Message msg) {
			// TODO Auto-generated method stub
			super.handleMessage(msg);
			//
			if (msg.what == MSG_WHAT_CHANGEVIEW){
				//
				ViewChageDataBean bean = (ViewChageDataBean)msg.obj; // 
				mMainActivityGroup.changeView(bean.current, bean.next, (Object)bean.bundlebean);
			}
		}};
		
	//date
	private List<GetItemListBean> itemListBeanData = new ArrayList<GetItemListBean>();
	private List<GetContentListBean> contentListData = new ArrayList<GetContentListBean>();
	private List<GetMakeBean> getMakeData = new ArrayList<GetMakeBean>();
	private List<SearchContentBean> searchContentData = new ArrayList<SearchContentBean>(); 
	private List<GetMsgBean> getMsgData = new ArrayList<GetMsgBean>();
	private GetContentBean contentSingle = new GetContentBean();
	private SearchConditionedBean searchConditioned = new SearchConditionedBean();
	private String itemName = "";
	//
	public iiiApplication() {
		// TODO Auto-generated constructor stub
	}
	
	@Override
	public void onCreate() {
		// TODO Auto-generated method stub
		super.onCreate();
		//
		// check debug flag...
		isDebug = isDebugMode();
		// create utility...
		mUtils = new Utils(this);		
		// initialize manager...
//		DEVICE_TOKEN = ((TelephonyManager) this.getSystemService(Context.TELEPHONY_SERVICE)).getDeviceId();
//		DEVICE_TOKEN ="dsdfwefwef";
		ResourceManager.getInstance().init(this);
		KenEventManager.getInstance().init(this);
	}
	
	public static void Log(String TAG, String Message){

		if (isDebug) Log.d(TAG, Message);
	}	
	
	private boolean isDebugMode(){
		boolean debug = false;
		PackageInfo packageInfo = null;
		try {
			packageInfo = this.getPackageManager().getPackageInfo(this.getPackageName(), PackageManager.GET_CONFIGURATIONS);
		} catch (NameNotFoundException e) {
			e.printStackTrace();
		}
		if (packageInfo != null) {
			int flags = packageInfo.applicationInfo.flags;
			if ((flags & ApplicationInfo.FLAG_DEBUGGABLE) != 0) {
				debug = true;
			}else
				debug = false;
		}
		return debug;
	}
	
	public void setMainActivityGroup(MainActivityGroup Group){
		mMainActivityGroup = Group;
	}
	
	public MainActivityGroup getMainActivityGroup(){
		return mMainActivityGroup;
	}
	
	public List<GetItemListBean> getItemListBeanData(){
		return this.itemListBeanData;
	}
	
	public void setItemListBeanData(List<GetItemListBean> date){
		itemListBeanData.clear();
		itemListBeanData.addAll(date);
	}
	
	public List<GetContentListBean> getContentListBeanData(){
		return this.contentListData;
	}
	
	public void setContentListBeanData(List<GetContentListBean> date){
		contentListData.clear();
		contentListData.addAll(date);
	}
	
	public List<GetMakeBean> getGetMakeBeanData(){
		return this.getMakeData;
	}
	
	public void setGetMakeBeanData(List<GetMakeBean> date){
		getMakeData.clear();
		getMakeData.addAll(date);
	}
	
	public List<SearchContentBean> getSearchContentData(){
		return this.searchContentData;
	}
	
	public void setSearchContentData(List<SearchContentBean> date){
		searchContentData.clear();
		searchContentData.addAll(date);
	}
	
	public List<GetMsgBean> getMsgData(){
		return this.getMsgData;
	}
	
	public void setMsgData(List<GetMsgBean> date){
		getMsgData.clear();
		getMsgData.addAll(date);
	}
	
	public GetContentBean getContentSingleBeanData(){
		return this.contentSingle;
	}
	
	public void setContentSingleBeanData(GetContentBean date){
		contentSingle = null;
		contentSingle = date;
	}
	
	public SearchConditionedBean getSearchConditionedData(){
		return this.searchConditioned;
	}
	
	public void setSearchConditionedData(SearchConditionedBean date){
		searchConditioned = null;
		searchConditioned = date;
	}
	
	public String getItemName(){
		return this.itemName;
	}
	
	public void setItemName(String itemname){
		this.itemName = itemname;
	}
	
	public void setDEVICE_TOKEN(String token){
		DEVICE_TOKEN =token;
	}
}
